﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Tizer.Web.Backoffice.Controls
{
    /// <summary>
    /// Контрол сообщений
    /// </summary>
    public partial class AdminMessage : System.Web.UI.UserControl
    {
        /// <summary>
        /// Загрузка страницы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
         

        }

        /// <summary>
        /// Показать сообщение
        /// </summary>
        /// <param name="title"></param>
        /// <param name="msg"></param>
        public void SetMessage(string title, string msg)
        {
            SetMessage(title, msg, MessageType.Info);
        }

        /// <summary>
        /// Показать сообщение
        /// </summary>
        /// <param name="title">Заголовок</param>
        /// <param name="msg">Сообщение</param>
        /// <param name="messageType">Тип сообщения</param>
        public void SetMessage(string title, string msg, MessageType messageType)
        {
            switch (messageType)
            {
                case MessageType.Error:
                    pnlMessage.CssClass = "alert-message block-message error";
                    break;
                case MessageType.Info:
                    pnlMessage.CssClass = "alert-message block-message info";
                    break;
                case MessageType.Success:
                    pnlMessage.CssClass = "alert-message block-message success";
                    break;
                case MessageType.Warning:
                    pnlMessage.CssClass = "alert-message block-message warning";
                    break;
                default:
                    pnlMessage.CssClass = "alert-message block-message info";
                    break;
            }

            litMessageTitle.Text = title;
            litMessageText.Text = msg;
            pnlMessage.Visible = true;
        }
    }

    /// <summary>
    /// Перечисление типов сообщения
    /// </summary>
    public enum MessageType
    {
        Error,
        Info,
        Success,
        Warning
    }
}